<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="player.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="error.jsp" %>
<%@ include file="header.jspf" %>
<%@ include file="team_header.jspf" %>

<%
    Player player = PlayerFabric.getInstance(((Integer) session.getAttribute("sport")).intValue());
%>

<section class="middle">

    <div class="wide-teaser">
        <h3>Add player</h3>
        <br class=clear>

        <table class="search-table" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <th>First Name:
                        <input type=text name="firstName" class="search-input" onkeyup="StringChecker(this)"> </th>
                    <th>Last Name:
						<input type=text name="lastName" class="search-input" onkeyup="StringChecker(this)"> </th>
                    <th>Position:
						<input type=text name="position" class="search-input" onkeyup="StringChecker(this)"> </th>
                    <th>Born in:
						<input type=text name="dateOfBirth" class="search-input" onkeyup="IntChecker(this)"> </th>
                    
                    
                </tr>
                <tr>
                    <th>Country:
						<input type=text name="country" class="search-input" onkeyup="StringChecker(this)"> </th>
                    <th>Height:
                        <input type=text name="height" class="search-input" onkeyup="DoubleChecker(this)"> </th>
                    <th>Weight:
						<input type=text name="weight" class="search-input" onkeyup="DoubleChecker(this)"> </th>
                </tr>
            </tbody>
        </table>
        <br>
        <h3>Stats:</h3>
                                        
        <br>
        <table class="search-table" cellspacing="0" cellpadding="0">
            <tbody>
                <%
                    if (player != null) {
                        List attrs = player.getAttrsNames();
                        List inputs = new ArrayList();
                        for (int i = 0; i < attrs.size(); i++) 
                            if (!attrs.get(i).equals("dateOfBirth") &&!attrs.get(i).equals("height") &&!attrs.get(i).equals("weight") &&!attrs.get(i).equals("teamId") &&!attrs.get(i).equals("country") &&!attrs.get(i).equals("lastName") && !attrs.get(i).equals("firstName") && !attrs.get(i).equals("position") && !attrs.get(i).equals("id") && !attrs.get(i).equals("sportId")) 
                            inputs.add(attrs.get(i));
                        for (int j = 0; j < inputs.size(); j++)    
                            if (j % 3 == 0) {
                %>
                <tr>
                    <th class="criterion"><%=inputs.get(j)%>:</th>
                    <th>                        
                        &nbsp;&nbsp;<input type=text name="<%=inputs.get(j)%>" class="search-input">                        
                    </th>
                    <%
                    } else if (j % 3 == 1) {%>
                    <th class="criterion"><%=inputs.get(j)%>:</th>
                    <th>                        
                        &nbsp;&nbsp;<input type=text name="<%=inputs.get(j)%>" class="search-input" >
                    </th>
                    <%
                    } else if (j % 3 == 2) {%>
                    <th class="criterion"><%=inputs.get(j)%>:</th>
                    <th>                        
                        &nbsp;&nbsp;<input type=text name="<%=inputs.get(j)%>" class="search-input">
                    </th>
                </tr> <%
                }
                
                                                       }
                                              
                
                %>    
					
				

            </tbody>
        </table>
        <br>
        <br class=clear>
        <button class=sportbutton onclick="add('player')">add</button>
        &nbsp;
        <button class=sportbutton onclick="window.location='roster.jsp';">cancel</button>

    </div>
</section>

<%@ include file="footer.jspf" %>